package com.connection.second.wallpaper.mapper;

import java.util.List;

import com.connection.second.common.annotation.AutoFill;
import com.connection.second.common.enums.OperationType;
import com.connection.second.wallpaper.domain.entity.PaperUserPosting;
import com.connection.second.wallpaper.domain.vo.UserPostingStatistics;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * 发布审核Mapper接口
 * 
 * @author FL
 * @date 2024-11-15
 */
@Mapper
public interface PaperUserPostingMapper 
{
    /**
     * 查询发布审核
     * 
     * @param id 发布审核主键
     * @return 发布审核
     */
    public PaperUserPosting selectPaperUserPostingById(Long id);

    /**
     * 查询发布审核列表
     * 
     * @param paperUserPosting 发布审核
     * @return 发布审核集合
     */
    public List<PaperUserPosting> selectPaperUserPostingList(PaperUserPosting paperUserPosting);

    /**
     * 新增发布审核
     * 
     * @param paperUserPosting 发布审核
     * @return 结果
     */
    @AutoFill(value = OperationType.INSERT)
    public int insertPaperUserPosting(PaperUserPosting paperUserPosting);

    /**
     * 修改发布审核
     * 
     * @param paperUserPosting 发布审核
     * @return 结果
     */
    @AutoFill(value = OperationType.UPDATE)
    public int updatePaperUserPosting(PaperUserPosting paperUserPosting);

    /**
     * 删除发布审核
     * 
     * @param id 发布审核主键
     * @return 结果
     */
    public int deletePaperUserPostingById(Long id);

    /**
     * 批量删除发布审核
     * 
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deletePaperUserPostingByIds(Long[] ids);

    @Select("SELECT update_time as `date`, COUNT(*) as count FROM paper_user_posting GROUP BY `date`")
    List<UserPostingStatistics> getUserPostStatistics();

    @Select("SELECT COUNT(*) FROM paper_user_posting WHERE user_id = #{userId}")
    Long countUserPosting(Long userId);
}
